//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - SaaS Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================


namespace Shp.Runtime.Contract
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.Serialization;

    [DataContract, Serializable]
    public class GuidStringPair
    {
        public GuidStringPair()
        {
        }

        public GuidStringPair(Guid key, string value)
        {
            _key = key;
            _value = value;
        }

        private Guid _key;
        [DataMember]
        public Guid Key
        {
            get { return _key; }
            set { _key = value; }
        }

        private string _value;
        [DataMember]
        public string Value
        {
            get { return _value; }
            set { _value = value; }
        }

        static public bool ContainsKey(Guid key, IList<GuidStringPair> list)
        {
            foreach (GuidStringPair pair in list)
            {
                if (pair.Key == key)
                {
                    return true;
                }
            }
            return false;
        }

        static public GuidStringPair Get(Guid key, IList<GuidStringPair> list)
        {
            foreach (GuidStringPair pair in list)
            {
                if (pair.Key == key)
                {
                    return pair;
                }
            }
            throw new ArgumentOutOfRangeException();
        }

        static public GuidStringPair[] Remove(Guid key, IList<GuidStringPair> list)
        {
            List<GuidStringPair> tmp = new List<GuidStringPair>();
            foreach (GuidStringPair pair in list)
            {
                if (pair.Key != key)
                {
                    tmp.Add(pair);
                }
            }
            return tmp.ToArray();
        }
    }
}
